﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using System.Security.Permissions;

namespace Model
{
    [Serializable]
    public class ProductStore:ISerializable
    {
        [Key]

        public int StoreId { get; set; }

        [ForeignKey("Product")]
        public string ProductId { get; set; }
        public DateTime StoreEnterDate { get; set; }
        public decimal StorePriceByUnit { get; set; }
        public int StoreQuantity { get; set; }
        public virtual Product Product { get; set; }

        public ProductStore()
        {

        }
        public ProductStore(SerializationInfo info, StreamingContext context)
        {
            ProductId = info.GetString("ProductId");
            StoreEnterDate = info.GetDateTime("StoreEnterDate");
            StorePriceByUnit = info.GetInt32("StorePriceByUnit");
            StoreQuantity = info.GetInt32("StoreQuantity");
        }

        [SecurityPermissionAttribute(SecurityAction.Demand, SerializationFormatter = true)]
        public void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            info.AddValue("StoreEnterDate", StoreEnterDate);
            info.AddValue("ProductId", ProductId);
            info.AddValue("StorePriceByUnit", StorePriceByUnit);
            info.AddValue("StoreQuantity", StoreQuantity);
        }
    }
}
